// File Name: usart_logic.c
// Author: kukukukuku~
// Date: 2024-10-24

#include "./USART/inc/usart_logic.h"
#include "apm32f00x_usart.h"

/**
 * @brief   USART发送数据
 * @param   data:       数据源
 * @param   dataLen:    数据长度
 * @retval  None
 * @note    None
*/
void usart_send_data(uint8_t const * const data, const uint16_t dataLen)
{
    if(data == NULL || dataLen == 0)
        return;
    
    for(uint16_t i = 0; i < dataLen; i++)
    {
        while(!USART_ReadStatusFlag(USART_USART, USART_FLAG_TXC));
        USART_TxData8(USART_USART, data[i]);
    }
    
    while(!USART_ReadStatusFlag(USART_USART, USART_FLAG_TXC));
}
